
package Game;

import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import java.util.Random;


public class FPSPlayer extends Node {
    private Spatial model;
    private int mapsize;

    public FPSPlayer(String id, Spatial model) {
        super(id);
        //this.mapsize = mapsize;
        setModel(model);
    }

    public void randomPosition(){
        float zahl1 = (new Random()).nextInt(1024);
        float zahl2 = (new Random()).nextInt(1024);
        this.setLocalTranslation(zahl1,zahl2,JMEGraphic.getHeight(zahl1, zahl2));
    }

    public void setPosition(NodePosition position) {
        this.setLocalTranslation(position.float_pos[0], position.float_pos[1], position.float_pos[2]);
    }

    public float[] getPosition(){
        return new float[]{this.getLocalTranslation().x, this.getLocalTranslation().y, this.getLocalTranslation().z};
    }

    public Spatial getModel() {
        return model;
    }
    
    public void setModel(Spatial model) {
        this.detachChild(this.model);
        this.model = model;
        this.attachChild(this.model);
        Quaternion rot = new Quaternion();
        rot.fromAngleAxis(-FastMath.HALF_PI, new Vector3f(0,1,0));
        model.setLocalRotation(rot);
    }

}
